package wo.esys.service.impl;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;

import wo.common.entity.WoPage;
import wo.esys.dto.MenuDto;
import wo.esys.mapper.MenuMapper;
import wo.esys.po.Menu;
import wo.esys.service.MenuService;

@Service
@Transactional
public class MenuServiceImpl implements MenuService {

	@Resource
	private MenuMapper menuMapper;
	
	@Override
	public WoPage<MenuDto> getPageData(Long page, Long rows, String searchContent) {
		// 采用分页插件，设置分页参数
		PageHelper.startPage(page.intValue(), rows.intValue());
		// 获取PO数据
		Page<Menu> pos = (Page<Menu>)menuMapper.findAllBySearch(searchContent);
		// 转DTO数据
		return new WoPage<MenuDto>(MenuDto.getDtos(pos.getResult()), pos.getTotal());
	}

	@Override
	public void create(MenuDto m) {
		Menu po = m.createPO();
		menuMapper.create(po);
	}

}
